<template>
	<view class="formula-pages">
		<CustomNav :isBack="true" :topBgColor="topBgColor" title="巡察动态"></CustomNav>
		<image src="@/static/image/home/bg.png" class="bg-img"></image>
		<view class="info-block" :style="'margin-top:'+mt">
			<view class="search-block">
				<view class="iconfont icon-sousuo" @click="getDynamicsList(true)"></view>
				<input class="search-input" v-model="listParam.title" placeholder-class="inputPlaceholder"
					placeholder="请输入关键字" />
			</view>
			<view class="info-item">
				<template v-if="list.length>0">
					<DynamicsList v-for="item in list" :key="item.id" :info="item"></DynamicsList>
				</template>
				<view v-if="more==false&&list.length==0" class="empty">暂无数据</view>
				<view v-else-if="more==false&&list.length>0" class="empty">没有更多了</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		isMore
	} from '@/util/util.js'
	import {
		DynamicsList
	} from '@/components/DynamicsList/DynamicsList.vue'
	import {
		getArticleListApi
	} from '@/api/home.js'
	export default {
		components: {
			DynamicsList
		},
		data() {
			return {
				listParam: {
					limit: 10,
					page: 1,
					type: 2,
					title: ''
				},
				list: [{
					id: 1,
					title: '十六届玉门市委第六轮巡察第三巡察组进驻市统计局党组开展巡察“回头看”！',
					time: '2024-10-19',
					viewCount: 63
				}, {
					id: 2,
					title: '玉门市委第五巡察组巡察“回头看” 市档案馆情况反馈会议召开',
					time: '2024-10-01',
					viewCount: 63
				}],
				more: true,
			}
		},
		methods: {
			handleRefresh() {
				this.listParam.page = 1;
				this.more = true
				this.getDynamicsList(true)
			},
			getDynamicsList(refresh = false) {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getArticleListApi(this.listParam).then(res => {
					let list = res.list || [];
					if (refresh) {
						this.list = list;
					} else {
						this.list = [...this.list, ...list]
					}
					this.more = isMore(this.listParam.page, this.listParam.limit, res.total)
				})
			}
		},
		onReachBottom() {
			if (this.more) {
				this.listParam.page++;
				this.getDynamicsList();
			}
		},
		onShow(e) {
			this.getDynamicsList(true);
		}
	}
</script>

<style lang="scss" scoped>
	.formula-pages {
		overflow: hidden;
		min-height: 100vh;
		background-color: #F7F6F9;

		.bg-img {
			width: 100%;
			height: 100%;
			position: absolute;
		}

		.info-block {
			position: relative;

			.search-block {
				width: $content-width;
				margin: 0 auto;
				height: 84rpx;
				background: #fff;
				border-radius: 20px;
				padding: 6rpx;
				display: flex;
				align-items: center;
				background-color: #F7F6F9;


				.iconfont {
					font-size: 44rpx;
					color: #4A8DFF;
					padding-left: 10rpx;
				}

				.search-input {
					height: 100%;
					flex-grow: 1;
					margin-left: 20rpx;
					font-size: 30rpx;
					color: #AAAAAA;
				}

				.inputPlaceholder {
					color: #AAAAAA;
				}
			}

			.info-item {
				background-color: #F7F6F9;
				padding: 30rpx;
				margin-top: 30rpx;
				border-radius: 50rpx 50rpx 0 0;
				min-height: 80vh;
			}
		}
	}
</style>